window.onload=function(){
    let password=document.getElementById('password');
    let tphone=document.getElementById('phone').nextElementSibling;
    let tduanxin=document.getElementById('duanxin').nextElementSibling;
    let tpassword=document.getElementById('password').nextElementSibling;
    let tpastword=document.getElementById('pastword').nextElementSibling;

    password.onkeyup=function(){
        let p=document.querySelectorAll('nav p');
        if(password.value.length==0){
            p[0].style.backgroundColor='#eeeeee';
            p[1].style.backgroundColor='#eeeeee';
            p[2].style.backgroundColor='#eeeeee';
        }
        else if(password.value.length>0 && password.value.length<6){
            
            p[0].style.backgroundColor='green';
            p[1].style.backgroundColor='#eeeeee';
            p[2].style.backgroundColor='#eeeeee';
        }
        else if(password.value.length>=6 && password.value.length<10){
                p[0].style.backgroundColor='orange';
                p[1].style.backgroundColor='orange';
                p[2].style.backgroundColor='#eeeeee';
        }
        else if(password.value.length>=10){
                p[0].style.backgroundColor='red';
                p[1].style.backgroundColor='red';
                p[2].style.backgroundColor='red';
        }
    }
// 电话号码长度
    document.getElementById('phone').onkeyup=function(){
        if(document.getElementById('phone').value.length<11){
            tphone.classList.remove('tphone');
            tphone.classList.add('active');
        }
        else{
            tphone.classList.remove('active');
            tphone.classList.add('tphone');
        }
        
    }

    document.getElementById('duanxin').onclick=function(){
        tduanxin.classList.remove('tduanxin');
        tduanxin.classList.add('active');
    } 

    document.getElementById('password').onclick=function(){
        tpassword.classList.remove('tpassword');
        tpassword.classList.add('active');
    }
    //确认密码
    document.getElementById('pastword').onkeyup=function(){
        let a=document.getElementById('password').value;
        let b=document.getElementById('pastword').value;
        if(a==b){
            tpastword.classList.remove('active');
            tpastword.classList.add('tpastword');
        }
        else{
            tpastword.classList.remove('tpastword');
            tpastword.classList.add('active');
        }
    }
}